import 'package:flutter/material.dart';
import 'package:flutterlib/common/config/config.dart';
import 'package:flutterlib/common/style/quhui_style.dart';

class WidgetWithNum extends StatelessWidget {
  const WidgetWithNum(
      {Key key,
      @required this.imgUrl,
      @required this.num,
      @required this.onPress})
      : super(key: key);

  final String imgUrl;
  final int num;
  final VoidCallback onPress;

  @override
  Widget build(BuildContext context) {
    var widgetWithNum = Stack(
      children: <Widget>[
        InkWell(
          onTap: onPress,
          child: Container(
            width: 50,
            height: 50,
            alignment: Alignment.center,
            child: Image(
                image: new AssetImage(Config.ASSETS_IMG + imgUrl),
                width: 25,
                height: 25),
          ),
        ),
        Positioned(
          top: 0,
          right: 10,
          child:
            Text(
                num == 0 ? "" : num.toString(),
              style: QuhuiConstant.smallTextRedBold,
            )
        )
      ],
    );
    return widgetWithNum;
  }
}
